﻿using System.Collections;

namespace Map_Creator.RedoUndo.Actions
{
    class ListRemoveAction :IAction
    {
        private IList list;
        private int index;
        private object oldItem;

        public ListRemoveAction(IList list, int index)
        {
            this.list = list;
            this.index = index;
            oldItem = list[index];
        }

        public void Do()
        {
            list.RemoveAt(index);
        }

        public void Undo()
        {
            list.Insert(index,oldItem);
        }

        public string GetDescription()
        {
            return "Remove From List At Index " + index;
        }

        public string GetName()
        {
            return "List Remove";
        }
    }
}
